-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async_hooks: skip sanity checks when disabled #15454
async_hooks: skip sanity checks when disabled #15454
Conversation
/cc @nodejs/async_hooks @mcollina |
👍
As for the current implementation, I'd like to see it more encapsulated, maybe like: const { validateAsyncId, validateTriggerId } = process.binding('async_wrap')
...
const id = validateAsyncId(argId); cpp Environment::AsyncHooks::validate_ids(double async_id, double trigger_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm definitely 👍 on this approach. Before landing we should verify that we do not break shot and hapi tests, even with async_hooks enabled: http://npm.im/shot.
There is a plan to move domains on top of async-hooks and the hapi community use domains.
@refack I've created a validation function on the JS side. On the C++ side, I would prefer to keep it as it. There aren't that many validations and only the line where the macro is used is shown in the error. If I merge those asserts it will be more difficult to know which assert failed. I will look into adding the flag. |
@refack I've added a |
doc/api/cli.md
Outdated
--> | ||
|
||
Enables sanity checks for async_hooks. These can also be enabled in runtime | ||
by enabling one of the `async_hooks` hooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intent to leave this flag in forever?
Also, would prefer to take -sanity
out... just --async-hooks-check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intent to leave this flag in forever?
Hopefully, we can become so robust the checks are always enabled.
Also, would prefer to take
-sanity
out... just--async-hooks-check
That is fine :)
lib/async_hooks.js
Outdated
if (triggerAsyncId !== null) | ||
validateAsyncId(triggerAsyncId, 'triggerAsyncId'); | ||
if (async_hook_fields[kSanityCheck] > 0 && | ||
(typeof type !== 'string' || type.length <= 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is missing a single space here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. The linter says it is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. another one of those things we do so regularly I didn't realize we needed a linter fix for. If you run this you'll see that >90% of these would have one more space
git grep -A 1 " if (.*[^{);]$" lib/
i'll check on getting a rule into the linter.
I probably should have come up with this sooner, but how about just printing warnings in these cases instead of crashing, and that unconditionally? That should help find bugs while at the same time preventing crashes … |
My understand from @trevnorris was that it would leave |
I like it. Maybe the names need some bikeshedding, but I have no strong opinions. |
Maybe one more thing, add the CLI flag to Lines 3936 to 3943 in 1a0727d
(had an idea for CLI flag name |
Sorry, I don't understand what you mean. Could you be very explicit :) |
Bring it, I'm not so happy about the names either :) |
Lines 3941 to 3946 in 1a0727d
In order for the new arg to be able to be used via NODE_OPTIONS it needs to be added to the whitelist, and probably to the test test/parallel/test-cli-node-options.js (or to the negative test test/parallel/test-cli-node-options-disallowed.js` if we decide to blacklist it).
As for the arg name IMHO it's missing a verb. I think |
I think just avoiding the word "sanity" throughout would be better... everything else looks fine to me. |
src/node.cc
Outdated
@@ -3953,6 +3959,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env, | |||
"--trace-warnings", | |||
"--redirect-warnings", | |||
"--trace-sync-io", | |||
"--async-hooks-check", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@refack is this the line you are talking about?
lib/_http_outgoing.js
Outdated
let socketAsyncId = this.socket[async_id_symbol]; | ||
// If the socket was set directly it won't be correctly initialized | ||
// with an async_id_symbol. | ||
// TODO(AndreasMadsen): @trevnorris sugested some more correct solution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "suggested"
src/env-inl.h
Outdated
if (fields_[kSanityCheck] > 0) { | ||
CHECK_GE(async_id, 0); | ||
CHECK_GE(trigger_id, 0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. this is cool for release builds, but i think they should also always be on in debug builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are always on in tests, and you can `alias node='node --force-async-hooks-check' if you like. I think it is important that we have them opt-in in release builds too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And export NODE_OPTIONS=--force-async-hooks-check
.
I understand where this comes from but allowing the stack to possibly get corrupted makes my stomach turn. It also inhibits the usefulness of I do like that you've yanked out the value checks into a single function. |
@trevnorris we have been playing this game for a long time. I don't think we can go into LTS with node being this unstable. To my mind, it has little to do with Regarding |
@@ -7,23 +7,12 @@ const spawn = require('child_process').spawn; | |||
|
|||
const script = ` | |||
const assert = require('assert'); | |||
const async_wrap = process.binding('async_wrap'); | |||
const {kTotals} = async_wrap.constants; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if this were a “real” script out linter would expect spaces inside {}
… no big deal, tho :)
So the tl;dr is can we converge on all the errors before LTS (~40 days)? If not then IMHO we need this PR 🤷♂️ Maybe turn this back to always-on for |
P.S. Ironically those that do use |
Two test failures. Both appear to be unrelated.
rerunning AIX: https://ci.nodejs.org/job/node-test-commit-aix/nodes=aix61-ppc64/9499/ |
The AIX failure is being addressed by #16273. |
@richardlau thanks. Found the other too: #16301 We can land :) |
Landed in 7c079d1 |
I will prepear the |
PR-URL: #15454 Ref: #14387 Ref: #14722 Ref: #14717 Ref: #15448 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: nodejs/node#15454 Ref: nodejs/node#14387 Ref: nodejs/node#14722 Ref: nodejs/node#14717 Ref: nodejs/node#15448 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Ref: #15454 PR-URL: #16318 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Ref: nodejs/node#15454 PR-URL: nodejs/node#16318 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Ref: nodejs/node#15454 PR-URL: nodejs/node#16318 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
PR-URL: nodejs/node#15454 Ref: nodejs/node#14387 Ref: nodejs/node#14722 Ref: nodejs/node#14717 Ref: nodejs/node#15448 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Ref: nodejs/node#15454 PR-URL: nodejs/node#16318 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless either `--no-force-async-hooks-checks` is given from CLI arguments or any async_hook is enabled. Refs: nodejs#16318 Refs: nodejs#15454 (comment) Signed-off-by: Daeyeon Jeong [email protected]
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: nodejs#16318 Refs: nodejs#15454 (comment) Signed-off-by: Daeyeon Jeong [email protected]
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: nodejs#16318 Refs: nodejs#15454 (comment) Signed-off-by: Daeyeon Jeong [email protected]
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: nodejs#16318 Refs: nodejs#15454 (comment) Signed-off-by: Daeyeon Jeong [email protected]
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: nodejs#16318 Refs: nodejs#15454 (comment) Signed-off-by: Daeyeon Jeong [email protected]
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: #16318 Refs: #15454 (comment) Signed-off-by: Daeyeon Jeong [email protected] PR-URL: #43317 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: #16318 Refs: #15454 (comment) Signed-off-by: Daeyeon Jeong [email protected] PR-URL: #43317 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: #16318 Refs: #15454 (comment) Signed-off-by: Daeyeon Jeong [email protected] PR-URL: #43317 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: #16318 Refs: #15454 (comment) Signed-off-by: Daeyeon Jeong [email protected] PR-URL: #43317 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
This removes a comment relevant to runtime checks for `async_hooks`. Even if `async_hooks` is experimental, the check pointed by the comment is performed as default unless `--no-force-async-hooks-checks` is given from CLI arguments. Refs: nodejs/node#16318 Refs: nodejs/node#15454 (comment) Signed-off-by: Daeyeon Jeong [email protected] PR-URL: nodejs/node#43317 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
async_hooks
While async_hooks is experimental we should skip the sanity checks when async_hooks is disabled. If someone would like a flag as well, we could add another
async_hooks_field
that is> 0
when either the flag is used or the hooks are enabled. Should be trivial.This makes the sanity checks stricter when
async_hooks
is enabled, so be sure to run CITGM before merging this. However, sinceasync_hooks
is rarely enabled there shouldn't be any issues.CI: https://ci.nodejs.org/job/node-test-pull-request/10120/
Ref: #14387
Ref: #14722
Ref: #14717
Ref: #15448